package net.wofly.sale.commodity.validator;

import org.springframework.util.StringUtils;

import net.wofly.sale.commodity.domain.CommodityType;

public class CommodityTypeValidator {
	
	/**
     * 换行符
     */
    private static String lineSeparator = System.getProperty("line.separator");

    public static String validateAddCommodityTypeInParams(CommodityType commodityType) {
        StringBuffer stringBuffer = new StringBuffer();
        
        if (StringUtils.isEmpty(commodityType.getCommodityTypeName())) {
            stringBuffer.append("商品类型名称不能为空").append(lineSeparator);
        }
        
        return stringBuffer.toString();
    }
    
    public static String validateUpdateCommodityTypeInParams(CommodityType commodityType) {
        StringBuffer stringBuffer = new StringBuffer();
        
        if (StringUtils.isEmpty(commodityType.getCommodityTypeID())) {
            stringBuffer.append("商品类型ID不能为空").append(lineSeparator);
        }
        
        if (StringUtils.isEmpty(commodityType.getCommodityTypeName())) {
            stringBuffer.append("商品类型名称不能为空").append(lineSeparator);
        }
       
        return stringBuffer.toString();
    }
    
    public static String validateCommodityTypeID(String commodityTypeID) {
        StringBuffer stringBuffer = new StringBuffer();
        
        if (StringUtils.isEmpty(commodityTypeID)) {
            stringBuffer.append("商品类型ID不能为空").append(lineSeparator);
        }
        
        return stringBuffer.toString();
    }

}
